import request from '@/utils/request'

// 菜单数据
export interface ResourceData {
    id?: number;
    name?: string;
    title?: string;
    code?: string;
    icon?: string;
    path?: string;
    component?: string;
    query?: string;
    perms?: string;
    parentId?: number;
    redirect?: number;
    type?: number;
    sort?: number;
    status?: number;
    hidden?: number;
}

// 查询参数
export interface ResourceParams extends Partial<ResourceData> {
    startDate?: string;
    endDate?: string;
}

// 菜单列表
export function treeResource(params: ResourceParams) {
    return request<ResourceData[]>('get', '/resource/tree', { params })
}

// 新增菜单
export function saveResource(data: ResourceData) {
    return request('post', '/resource', data)
}

// 修改菜单
export function updateResource(data: ResourceData) {
    return request('put', '/resource', data)
}

// 删除菜单
export function deleteResource(ids: any) {
    return request('delete', '/resource/' + ids)
}
